export const formatAdvanceParams = (params) => {
  for (const key in params) {
    if (Object.prototype.hasOwnProperty.call(params, key)) {
      const value = params[key];
      if (Object.prototype.toString.call(value) === "[object Array]") {
        params[key] = params[key].join(",")
      }
      
      if (Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
        delete params[key]
      }

      if (Object.prototype.toString.call(value) === "[object String]" && value === "") {
        delete params[key]
      }
    }
  }
  return params
};

export const formatParamsToUrl = (params) => {
  const keys = Object.keys(params)
  const values = Object.values(params)
  const datas = []
  for (let i = 0; i < keys.length; i++) {
    datas.push(`${keys[i]}=${values[i]}`)
  }
  return `?`+datas.join("&")
};